package edu.mtu.citizenscience.cs.notepad.model.note;

import java.util.Date;

import com.openswimsoftware.orm.model.ModelFile;
import com.openswimsoftware.orm.model.annotation.Parent;

import android.content.Context;

import edu.mtu.citizenscience.cs.notepad.model.ModelNote;
/**
 * @author Corbin Uselton <corbinu@cwuselto@mtu.edu>
 * @copyright (c) 2012 MichiganTech <http://www.mtu.edu>
 * @since 1.0
 * 
 * Model of an image in the app DB
 * has a file path, and date taken
 * It also belongs to a note
 */
public class ModelImage extends ModelFile<ModelImage> {
	// reference var for passing image model id between activities
	public static final String IMAGE_ID = "IMAGE_ID";
	
	// date time the image was taken
	private Date date;
	
	// the location's parent note
	@Parent
	private ModelNote note;
	
	/**
	 * Create the image model
	 * 
	 * @param   context - Context - context for model operations
	 * @return	void
	 */
	public ModelImage(Context context) 
	{
		super(context, ModelImage.class);
	}

	/**
	 * Create the image model
	 * 
	 * @param   context - Context - context for model operations
	 * @param	id - long - the model id to load from the DB
	 * @return	void
	 */
	public ModelImage(Context context, long id) 
	{
		super(context, ModelImage.class, id);
	}
	
	/**
	 * Get the image's parent note
	 * 
	 * @param   void
	 * @return	ModelNote - The images parent note
	 */
	public ModelNote getNote()
	{
		// make sure the model is loaded
		this.load();
				
		return this.note;
	}
	
	/**
	 * Set the images's parent note
	 * 
	 * @param   note - ModelNote - The images parent note
	 * @return	void
	 */
	public void setNote(ModelNote note)
	{
		// mark the model as updated
		this.updated = true;
		
		this.note = note;
	}
	
	/**
	 * Get the image's date
	 * 
	 * @param   void
	 * @return	Date - The images date
	 */
	public Date getDate()
	{
		// make sure the model is loaded
		this.load();
		
		return this.date;
	}
	
	/**
	 * Set the image's date
	 * 
	 * @param   date - Date - The images date
	 * @return	void
	 */
	public void setDate(Date date)
	{
		// mark the model as updated
		this.updated = true;
		
		this.date = date;
	}

}
